<template>
	<view class="transfor">
		<view class="person">
			<view class="personTitle">
				<view class="personImg">
					<image :src="person.avatar"></image>
				</view>
				<view class="personText">
					<text>{{person.name}}</text>
					<text>({{person.code}})</text>
				</view>
			</view>
		</view>
		<view class="transforBox">
			<view class="transforTitle">转账金额</view>
			<view class="transforInput">
				<text>￥</text>
				<input type="number" v-model="money"/>
			</view>
			<view class="transforBtn" @click="recharge">
				充值
			</view>
		</view>
		
	</view>
</template>

<script>
	import {info} from "@/api/user";
	import {commit} from "@/api/account"
	export default {
		data() {
			return {
				person:{},
				money:Number
			}
		},
		methods: {
			async info(){
				const {data:res} = await info()
				// console.log(res)
				this.person = res
			},
			async recharge(){
				if(this.money==0&&this.money<0){
					uni.showToast({
						title:'请输入充值金额'
					})
					this.money=''
					return
				}
				let amount = this.money
				const res = await commit(amount)
				// console.log(res)
				if(res.code==10000){
					uni.showToast({
						title:'充值成功',
						success() {
							setTimeout(()=>{
								uni.navigateBack()
							},1000)
						}
					})
				}else{
					uni.showToast({
						title:'充值失败'
					})
					this.money = ''
				}
			}
		},
		onLoad() {
			this.info()
		}
	}
</script>

<style lang="stylus" scoped>
.transfor
	height 100vh
	.person
		width 100%
		display flex
		justify-content center
		.personTitle
			.personImg
				width 80rpx
				height 80rpx
				margin 0 auto
				image
					width 80rpx
					height 80rpx
			.personText
				margin-top 18rpx
				display flex
				justify-content center
				
	.transforBox
		padding 90rpx 60rpx
		width 100%
		.transforTitle
			font-size 24rpx
			font-weight 300
		.transforInput
			display flex
			margin-top 60rpx
			text
				font-size 72rpx
				font-weight 600
			input
				width 100%
				height 100%
				font-size 72rpx
		.remark
			width 100%
			height 88rpx
			border 1rpx solid #DD524D
		.transforBtn
			margin-top 100rpx
			border-radius 30rpx
			width 100%
			height 88rpx
			background-color #F7895E
			display flex
			justify-content center
			align-items center
			color #fff
</style>

